<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\common\model\Area as ModelArea;

class Area extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];
    public function getAreaList()
    {
        $pid = input('pid', 0);
        $type = input('type', 1);
        if ($type == 1) {
            $areaList = ModelArea::where('pid', $pid)->field('id,name')->order('id')->select();
            // 去掉全部选项
            array_shift($areaList);
        } else {
            $areaList = ModelArea::where('pid', $pid)->field('id,name')->order('id')->select();
        }
        $this->success('获取成功', $areaList);
    }
}
